﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HFController;
using System.Web.Script.Serialization;
using System.Web.SessionState;

namespace HFWebApp.AjaxSource
{
    /// <summary>
    /// UserReg 的摘要说明
    /// </summary>
    public class UserReg : IHttpHandler, IRequiresSessionState
    {
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            BagePages bp = new BagePages();
            string uid = bp.GetAll("uid");
            string pwd = bp.GetAll("pwd");
            string pwd2 = bp.GetAll("pwd2");
            string email = bp.GetAll("email");

            HFModel.ResultModel result = new HFModel.ResultModel();
            result = UserController.getController().doAddUser(uid, pwd, pwd2, email);
            if (result.isTrue)
            {
                result.goUrl = bp.getDemain + "/user/usercenter.aspx";
            }
            context.Response.Write(this.getJSONResult(result));
            context.Response.End();
        }
        protected string getJSONResult(HFModel.ResultModel result)
        {
            JavaScriptSerializer jsSerializer = new JavaScriptSerializer(new SimpleTypeResolver());
            return jsSerializer.Serialize(result);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}